package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.BaseInfoDao;
import cn.topevery.garden.entity.oneMap.CountVO;
import cn.topevery.garden.entity.po.BaseInfo;
import cn.topevery.garden.entity.query.BaseInfoQuery;
import cn.topevery.garden.entity.vo.BaseInfoVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author code-generate
 * @date 2022-01-05
 */
@Service
public class BaseInfoLogic extends BaseLogic<BaseInfo> {
    @Autowired
    BaseInfoDao baseInfoDao;

    @Override
    public BaseEntityDao<BaseInfo, Integer> getDao() {
        return baseInfoDao;
    }


    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<BaseInfoVO> listPage(BaseInfoQuery query) {
        return baseInfoDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId, Integer[] ids) {
        baseInfoDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param baseInfo 实体
     */
    public void saveOrUpdate(String userId, BaseInfo baseInfo) {
        baseInfoDao.saveOrUpdate(userId, baseInfo);
    }

    /**
     * 根据自定义列值来获取对象
     */
    public BaseInfo getEntityByColumn(String key, String value) {
        return baseInfoDao.getEntityByColumn(key, value);
    }

    public DataPager<BaseInfo> getPage(BaseInfoQuery query) {
        return baseInfoDao.getPage(query);
    }

    public void commit(BaseInfo baseInfo, Integer userId) {
        baseInfoDao.commit(baseInfo, userId);
    }

    public void deleteById(Integer id, Integer userId) {
        baseInfoDao.deleteById(id, userId);
    }

    public List<CountVO> getSurvey(List<String> types) {
        return baseInfoDao.getSurvey(types);
    }
}
